<template>
  <view class="goods-item">
    <!-- 左侧的盒子 -->
    <view class="goods-item-left">
      <image :src="goods.goods_small_logo || defaultPic" class="goods-pic"></image>
    </view>
    <!-- 右侧的盒子 -->
    <view class="goods-item-right">
      <!-- 商品的名字 -->
      <view class="goods-name">{{goods.goods_name}}</view>
      <view class="goods-info-box">
        <view class="goods-price">￥{{goods.goods_price | tofixed}}</view>
      </view>
    </view>
  </view>
</template>

<script>
  export default {
    props:{
      goods:{
        type:Object,
        default:{}
      }
    },
    name:"my-goods",
    data() {
      return {
        //设置默认图片的地址
        defaultPic:'https://image.baidu.com/search/detail?ct=503316480&z=&tn=baiduimagedetail&ipn=d&word=%E4%B8%8D%E5%AD%98%E5%9C%A8&step_word=&ie=utf-8&in=&cl=2&lm=-1&st=-1&hd=&latest=&copyright=&cs=1624744167,383630783&os=1073800287,820488424&simid=1624744167,383630783&pn=28&rn=1&di=7207123747399008257&ln=1531&fr=&fmq=1679909121786_R&ic=&s=undefined&se=&sme=&tab=0&width=&height=&face=undefined&is=0,0&istype=2&ist=&jit=&bdtype=0&spn=0&pi=0&gsm=1e&objurl=https%3A%2F%2F5b0988e595225.cdn.sohucs.com%2Fimages%2F20190412%2F7dc7cce27e4045438bf53f1b84b4c6a2.jpeg&rpstart=0&rpnum=0&adpicid=0&nojc=undefined&dyTabStr=MCwzLDIsNCwxLDYsNSw3LDgsOQ%3D%3D'
      };
    },
    //过滤器
    filters:{
      tofixed(num){
        return Number(num).toFixed(2)
      }
    }
  }
</script>

<style lang="scss">
.goods-item{
  display: flex;
  padding: 10px 5px;
  border-bottom: 1px solid #f0f0f0;
  .goods-item-left{
    margin: 5px;
    .goods-pic{
      width: 100px;
      height: 100px;
      display: block;
    }
  }
  .goods-item-right{
    display: flex;
    //纵向布局
    flex-direction: column;
    justify-content: space-between;
    .goods-name{
      font-size:13px;
    }
    .goods-info-box{
      .goods-price{
        color:#C00000;
        font-size: 16px;
      }
    }
    
  }
}
</style>